#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll T;
ll n,arr[100005],tmp[100005],ans,pos=1,ex;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%lld",&n);
    for(int i = 1;i<=n;i++) scanf("%lld",&arr[i]);
    sort(arr+1,arr+n+1);
    tmp[pos] = 1;
    for(int i = 2;i<=n;i++){
        if(arr[i]>arr[i-1]) pos++;
        tmp[pos]++;
    }
    //for(int i = 1;i<=pos;i++) printf("%lld ",tmp[i]);
    //printf("\n");
    ex = tmp[1];
    for(int i = 2;i<=pos;i++){
        if(tmp[i]>=ex){
            ans+=ex;
            ex = tmp[i];
        }
        else{
            ans+=tmp[i];
        }
    }
    printf("%lld",n-ans);
    return 0;
}
